<template>
  <div class="pd-20">
    <el-input v-model="content" type="textarea" :rows="35" placeholder="请输入用户需知"/>
    <p align="center" style="margin-top: 20px">
      <el-button @click="handleSave"
                 size="medium"
                 type="primary">保存
      </el-button>

    </p>
  </div>
</template>

<script>

export default {
  name: "index",
  data() {
    return {
      content: ''

    }
  },
  created() {
    this.getAgreement()
  },
  methods: {
    getAgreement() {
      this.post(this.api.slowDisease.getAgreement).then((res) => {
        if (res.data.code === '200') {
          this.content = res.data.object.content
        }
      })
    },
    saveAgreement() {
      this.post(this.api.slowDisease.saveAgreement, {
        content: this.content
      }).then((res) => {
        if (res.data.code === '200') {
          this.$message.success('更新成功')
        }
      })
    },
    handleSave() {
      if (this.content.trim())
        this.saveAgreement()
      else
        this.$message.warning('请输入用户需知')
    }
  }
}
</script>

<style scoped>

</style>
